import xlwt

# 创建book,并设定编码
workbook = xlwt.Workbook(encoding='ascii')
#创建新的sheet表
worksheet = workbook.add_sheet('new sheet')
pattern = xlwt.Pattern()
# 设置背景模式
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
# 设置单元格背景色
pattern.pattern_fore_colour = 52

style = xlwt.XFStyle()
style.pattern = pattern

# 写入内容
worksheet.write(0,0,'hello',style)

workbook.save('test7.xls')

